<template>
  <div class="student-analysis-item" v-if="studentInfo">
    <div class="item-left">
      <div class="student-info">
        <avatar :size="60" :src="studentInfo.pic" />
        <div class="student-name">{{ studentInfo.name }}</div>
        <n-icon size="24">
          <ChevronForwardOutline />
        </n-icon>
      </div>
      <div class="num-wrap">
        <div class="num-item">
          <div class="label">综合表现</div>
          &nbsp;
          <ExpressionEmoji :icon="scoreIcon" class="score-img" />
        </div>
        <div class="num-item">
          <div class="label">完成率</div>
          &nbsp;
          <div class="num">{{ wordNum.complete }}/{{ wordNum.total }}</div>
        </div>
      </div>
    </div>
    <div class="item-right">
      <n-scrollbar x-scrollable>
        <div class="handwriting-wrap" :style="`width: ${wordNum.complete * 150}px`">
          <template v-for="group in wordData">

            <Handwriting v-for="(item, i) in group.data" :key="i" :image="item.writeInfo.image" :label="item.writeInfo.label" :icon="item.writeInfo.icon" />
          </template>
        </div>
      </n-scrollbar>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { ChevronForwardOutline } from '@vicons/ionicons5';
  import Handwriting from '@/views/components/Handwriting/index.vue';
  import ExpressionEmoji from "@/views/components/ExpressionEmoji/index.vue";

  const props = defineProps({
    index: {
      type: Number,
      default: 1,
    },
    studentInfo: {
      type: Object,
      default: null,
    },
    scoreIcon: {
      type: String,
      default: 'icon',
    },
    wordNum: {
      type: Object,
      default: {
        complete: 0,
        total: 0,
      },
    },
    wordData: {
      type: Object,
      default: () => {},
    },
  });
</script>

<style scoped lang="less">
  .student-analysis-item {
    height: 192px;
    background-color: #fff;
    border-radius: 12px;
    margin-bottom: 18px;
    display: flex;
    overflow: hidden;
    cursor: pointer;
    .item-left {
      width: 360px;
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: center;
      padding: 18px 24px;
      position: relative;
      &::after {
        content: '';
        position: absolute;
        width: 1px;
        top: 18px;
        bottom: 18px;
        right: 0;
        background: linear-gradient(
          270deg,
          rgba(230, 234, 237, 0) 0%,
          #e6eaed 15%,
          #e8ecee 87%,
          rgba(230, 234, 237, 0) 100%
        );
      }
    }
    .item-right {
      width: 1488px;
      padding: 12px 24px;
    }
    .student-info {
      display: flex;
      align-items: center;
      .student-name {
        font-size: 24px;
        margin: 0 12px;
        flex: 1;
      }
    }
    .num-wrap {
      margin-top: 24px;
      height: 60px;
      display: flex;
      align-items: center;
      justify-content: center;
      background-color: #f6f8f9;
      .num-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        border-right: 1px solid #c0c3c5;
        &:last-child {
          border-right: none;
        }
        .score-img {
          width: 24px;
          height: 24px;
        }
        .label {
          color: #9ba2aa;
        }
      }
    }
  }
  ::v-deep(.n-scrollbar-content){
    height: 100%;
  }
  .handwriting-wrap {
    height: 100%;
    display: flex;
    align-items: center;

    .handwriting-item{
      margin-right: 54px;
    }
  }
</style>
